file=$1
ff2=$2
ff3=$3

ii=0

echo file $file
echo ff2 $ff2
echo ff3 $ff3

#double transverse

echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l <<EOF
.L style.cxx+
.L plotDoubleT.C+
plotECalPDG("$file",0)
plotECalPDG("$file",1)
plotECalPDG("$file",2)
plotECalPDG("$file",3)
plotECalPDG("$file",10)
plotECalPDG("$file",11)
.q
plotCCQEvsMuonPt("$file",2)
plotCCQEvsMuonPt("$file",1)
plotCCQEvsMuonPt("$file",0)
plotCCQEvsMuonPt("$file",12)
plotCCQEvsMuonPt("$file",11)
plotCCQEvsMuonPt("$file",10)
.q

plotEmissionFraction("$file",0)
plotEmissionFraction("$file",1)
plotVertex("$file",2)
plotVertex("$file",3)
.q

plotRatioNuclearEmission("$file",0)
plotRatioNuclearEmission("$file",1)
plotRatioNuclearEmission("$file",2)
.q



plotDeltaPTT("$file",20)
plotDeltaPTT("$file",21)
.q



plot2DkT("$file",0)
plot2DkT("$file",1)

plotDeltaPTT("$file",0)
plotDeltaPTT("$file",1)
plotDeltaPTT("$file",2)
plotDeltaPTT("$file",3)
plotDeltaPTT("$file",4)
plotDeltaPTT("$file",5)
plotDeltaPTT("$file",6)
.q
plotDeltaPTT("$file",8,0)
.q
plotDoubleT("$file",7)
.q
plotDeltaPTT("$file",7,0)
.q

plotDeltaPTT("$file",0,1)
plotDeltaPTT("$file",1,1)
plotDeltaPTT("$file",2,1)
plotDeltaPTT("$file",3,1)
plotDeltaPTT("$file",4,1)
plotDeltaPTT("$file",5,1)
plotDeltaPTT("$file",6,1)
.q

plotVertex("$file",0)
plotVertex("$file",1)
plotDoubleT("$file",1)
plotDoubleT("$file",2)
plotDoubleT("$file",3)
plotDoubleT("$file",4)
plotDoubleT("$file",5)
plotDoubleT("$file",6)
.q
EOF

exit

## task1

for kk in $(echo $file $ff2 $ff3)
do

 echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l <<EOF
.L style.cxx+
.L compilePlot.C+
plotStat("$kk")
.q
EOF

exit

for dd in $(seq -2 8)
do
    echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l <<EOF
.L style.cxx+
.L compilePlot.C+
ptBroadening($dd, "$file", "$ff2", "$ff3")
.q
EOF
done

done


exit


#echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L compilePlot.C+
#plotTPC()
#.q
#EOF

exit


echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L compilePlot.C+
plotFM()
.q
EOF

exit


    echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l <<EOF
.L style.cxx+
.L compilePlot.C+
plotPID("$kk")
.q
EOF

exit


#############  pt for both ND280 and SK
for kproton in $(echo 0 1)
do
#for formula in $(echo GausML CauchyML GausLS CauchyLS)
for formula in $(echo  CauchyML)
do
#for kSigmaMode in $(echo 1 0 2)
#for kSigmaMode in $(echo 1)
for kSigmaMode in $(echo 0 2)
do
    #for kZaxis in $(echo 0 1)
    for kZaxis in $(echo 0)
    do
        #for kTrueMu in $(echo 0 1)
        for kTrueMu in $(echo 1)
#misID not making sense
        do
            #for kNuDirOpt in $(echo 0 1 2)
            #for kNuDirOpt in $(echo 0 1)
            for kNuDirOpt in $(echo 1 5 6 7 8 9) #1 5 6 7 8 9 )
            do

#initial
                echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 0, 0, 0, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF

          echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 60, 0, 0, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF

   echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 30, 0, 0, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF

  echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 0, 1.5, 0, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF


  echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 0, 0.5, 0, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF

 echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 0, 0.1, 0, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF


  echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 0, 0, 0, 4, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF

  echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 0, 0, 0, 6, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF

continue

  echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 60, 0, 0, 4, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF



continue


#muon final duplicated
           echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 3.0, 80, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF

#larm 0.5 no improvement
          echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 60, 0.5, 0, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF

#nhit 70 does not improve
  echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 70, 0, 0, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF


continue

#maxchi 4
               echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 0, 0, 0, 1.5, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF

#               echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 0, 0, 0, 2, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#                echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 0, 0, 0, 3, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
####
               echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 0, 0, 0, 4, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF
#
#                echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 0, 0, 0, 5, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF

#nhit 60
#              echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 40, 0, 0, 4, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#              echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 50, 0, 0, 4, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
######
             echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 60, 0, 0, 4, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF
#
#              echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 70, 0, 0, 4, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#


#maxp 3.5 -> not used after using chi2
#              echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 0, 3, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#
#             echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 0, 3.5, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#              echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 0, 4, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#


#larm 1.5

#              echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.0, 0, 4, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#
             echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF
#
#              echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 2, 0, 4, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#

#charge -- no use
                
#              echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 3.5, 0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
##
#               echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 3.5, 1, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#               echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 3.5, 2, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#               echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 3.5, 3, 0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF


#fpath: 3 is good

#             echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 0, 2.0, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#             echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 0, 2.5, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
####
           echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 3.0, 0,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF

##
#             echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 0, 3.5, 0, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#

#range 0.5? --> not used, no different from straight path length
#             echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 0, 0, 0, 0.3, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#             echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 0, 0, 0, 0.4, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#             echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 0, 0, 0, 0.5, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#   
#          echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 0, 0, 0, 0.6, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF


#maxnhit 80 is good -- final

#            echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 3.5, 0, 3.0, 90, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#
#
           echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L style.cxx+
.L plotPtInvRes.C+
plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 0, 4, 3.0, 80,  $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
.q
EOF
#
#            echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
#.L style.cxx+
#.L plotPtInvRes.C+
#plotPtInvRes("$formula", $kSigmaMode, 60, 1.5, 3.5, 0, 3.0, 70, 0, $kZaxis, $kTrueMu, $kNuDirOpt, $kproton)
#.q
#EOF
#            

continue

done
    done
    done
        done
    done
done

##############################################################

for ff in $(echo \
    outplot/fitslicenhit* \
    )
do
    echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotFunc("$ff")
.q
EOF

done

exit

######################### PID and ptres inspection
for kproton in $(echo 0 1)
do
#for pp in $(echo 1 0)
for pp in $(echo 0)
do
    #for kk in $(echo PID CCeff PtRes CCpurity PRes)
    for kk in $(echo  PtRes )
    do
        for jj in $(echo \
            "fProtonRecChi2/fProtonRecNDOF" "fProtonRecNhits[0]" "fProtonRecFlightPath->Pt()"  "fMuonRecChi2/fMuonRecNDOF" "fMuonRecNhits[0]" "fMuonRecFlightPath->Pt()" )
#            "fMuonRecChi2/fMuonRecNDOF" "fMomErr/fMuonRec->P()" \
#"fMuonLength[0]" "fMuonLength[1]" "fMuonLength[2]" "fRangeMomentumMuon" \
#            "fMuonRec->Theta()*TMath::RadToDeg()" "fMuonAlphaRec" \
#            "fNeutrinoSim->Theta()*TMath::RadToDeg()" "fNeutrinoSim->E()" "fNeutrinoType" "fNeutMode" "fNeutrinoParentType" \
#            "fMuonRecEndPos->X()" "fMuonRecEndPos->Y()" "fMuonRecEndPos->Z()" "fMuonRecVertex->X()" "fMuonRecVertex->Y()" "fMuonRecVertex->Z()" \
#            "fMuonTypeSim" "fMuonRecFlightPath->Mag()" "fMuonRecFlightPath->Pt()" "fMuonRecNhits[0]" "fMuonRecNhits[1]" "(fMuonCharge[1]==-1)*2+(fMuonCharge[0]==-1)" \
#            "fMuonAlphaSim"  "fMuonRecPt->Mag()" "fMuonRec->P()"  "fMuonSimPt->Mag()" "fMuonSim->P()" "fQ2Sim" \
#            "fMultiplicity" \
#            )
        do
            echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l  <<EOF
.L style.cxx+
.L plotStack.C+
plotStack("$file","$jj", "$kk", $pp, $kproton)
.q
EOF
            
        done
    done
done
done
exit



############################################## 

#########################################################
#pt spectrum

kproton=0
for mode in $(seq 0 5)
do
    for jj in $(echo 0 1)
    do
        echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
ptSpectrum($jj, $mode,$kproton)
.q
EOF
    done
done

exit



################ lever arm study

for kk in $(seq 0 5)
do
    echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
fitLeverArm("$file",$kk)
.q
EOF

    echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
fitLeverArm("$file",$kk+10)
.q
EOF

done

exit



############# Stack

for jj in $(echo "fMuonSimPt->Mag()" "fMuonSim->P()" ) #"fMuonRecPt->Mag()" "fMuonRec->P()"  "fQ2Sim" "fNeutrinoSim->E()")
do
    for kk in $(echo Q2PPt ModePPt ) #EnuPPt ParentPPt)
    do
        echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotStack("$file","$jj", "$kk",1)
.q
EOF

  echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotStack("$file","$jj", "$kk",0)
.q
EOF
    done
done


exit


for kk in $(echo  MulPSelQ2 PtSelQ2)
do
    echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotStack("$file","fQ2Sim", "$kk",1)
.q
EOF
done




for jj in $(echo "fNeutrinoSim->E()" "fQ2Sim" "fMuonSim->P()" "fMuonSimPt->Mag()" "fMuonRec->P()" "fMuonRecPt->Mag()" )
do
    echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotStack("$file","$jj", "MultiplicityFraction",1)
.q
EOF
done


echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotStack("$file","fNeutrinoSim->E()", "EnuNCCC",0)
.q
EOF

for jj in $(echo "fNeutrinoSim->E()" "fQ2Sim"  "fMuonSimPt->Mag()" "fMuonSim->P()")
do
    
    echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotStack("$file","$jj", "CmpOsci", 0)
.q
EOF
    
done

exit



######################################

#only for ND280

###



########################

#only for SK

###

echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C 
plotResPtGuess()
.q
EOF

########################



echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotPtGuess()
.q
EOF

echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plot()
.q
EOF

echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotNuE("$2")
.q
EOF


echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotMom()
.q
EOF

echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotPtInv()
.q
EOF

echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotPt()
.q
EOF


echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotEMode(0)
.q
EOF

echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotEMode(1)
.q
EOF

echo "------------------------------------------------------------------------"; echo plotID=$ii; ii=$( expr $ii + 1 ); root -b -l $file <<EOF
.L plot.C
plotptMode()
.q
EOF
